home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln0286.arc
/
LAST.RAT
< prev
next >
Wrap
Text File
|
1986-02-03
|
4KB
|
159 lines
###########LISTING 1 FOLLOWS
while(<condition>)
<statement>
repeat
<statement>
[until(<condition>)]
for([<initialization>;[<condition>];[<increment>])
<statement>
do <index>=<first>,<last>[,<increment>]
<statement>
break [<n>]
next [<n>]
if(<condition>)
<statement>
[else
<statement>]
switch <variable>
{
case <constant>: <statement>
case <constant>: <statement>
...
[default: <statement>]
}
###########LISTING 2 FOLLOWS
program main #Main program
logical openio
CHARACTER name(10),readwr(2)
integer luns(2)
data luns/STDIN,STDOUT/,readwr/LETR,LETW/
call remark('RATFOR Translator.')
do ifile=1,2 #Open input and output files
{
do i=1,3
{
if(ifile==1)
call remark('Input file name? .')
else
call remark('Output file name? .')
read 1000,name; 1000 format(10a1)
if(openio(name,luns(ifile),readwr(ifile))) next 2 #Skip to next ifile if ok
}
call error('Too many tries.') #Exit if eithr LUN not opened
}
call parse #Translate RATFOR program to FORTRAN object file
call remark('RATFOR translation complete.')
end
###########LISTING 3 FOLLOWS
define(STRCHR,[ifelse($1,,,[,$1(STRLEN($2))])])
define(STRSTR,[ifelse($1,,[EOS],[1h]substr($1,1,1)[,strstr(substr($1,2))])])
define(STRCHR,[ifelse($1,,,[,$1(STRLEN($2))])])
define(STRDAT,[ifelse($1,,,[,$1/STRSTR($2)/])])
define(STRING,CHARACTER[$1(STRLEN($2))STRCHR($3,$4)STRCHER($3,$4)_
data $1/STRSTR($2)/STRDAT($3,$4)])
###########LISTING 4 FOLLOWS
define(TPI,6.2831853072)
subroutine fftdif(x,y,m) #Decimation in frequency FFT--reorder output
#Forward transform (negative exponential)
#Arguments:
# x Real input/output array
# y Imaginary input/output array
# m Dimension of x and y is 2**m
dimension x(1),y(1)
n=2**m
kjj=n
do k=1,m
{
nn=kjj
kjj=kjj/2
dthet=TPI/nn
do j=1,kjj
{
thet=(j-1)*dthet
c=cos(thet)
s=sin(thet)
do i1=j,n,nn
{
j1=i1+kjj
xs=x(i1)-x(j1)
ys=y(i1)-y(j1)
x(i1)=x(i1)+x(j1)
y(i1)=y(i1)+y(j1)
x(j1)=xs*c+ys*s
y(j1)=-xs*s+ys*c
}
}
}
call reordr(x,y,m)
return
end
subroutine fftdit(x,y,m) #Decimation in time FFT--reorder input
#Back transform (Positive exponential)
#Arguments:
# x Real input/output array
# y Imaginary input/output array
# m Dimension of x and y is 2**m
dimension x(1),y(1)
call reordr(x,y,m)
n=2**m
nn=1
do k=1,m
{
kjj=nn
nn=nn+nn
dthet=TPI/nn
do j=1,kjj
{
thet=(j-1)*dthet
c=cos(thet)
s=sin(thet)
do i1=j,n,nn
{
j1=i1+kjj
xs=x(j1)*c-y(j1)*s
ys=x(j1)*s+y(j1)*c
x(j1)=x(i1)-xs
y(j1)=y(i1)-ys
x(i1)=x(i1)+xs
y(i1)=y(i1)+ys
}
}
}
return
end
subroutine reordr(x,y,m) #Reorders data for FFT input or output
#Arguments:
# x Real input/output array
# y Imaginary input/output array
# m Dimension of x and y is 2**m
dimension x(1),y(1)
n=2**m
do i=1,n
{
k=i-1 #Reverse-bit k to form j-1
j=1
ib=n
do l=1,m #Add bits to j-1 from top down where bits exist in k from bottom up
{
ib=ib/2
kn=k/2
j=j+(k-kn*2)*ib
k=kn
}
if(j>i) #Interchange and conjugate array elements if j>i
{
q=x(j)
x(j)=x(i)
x(i)=q
q=y(j)
y(j)=-y(i)
y(i)=-q
}
else if(i==j) #Conjugate only if j==i
y(i)=-y(i)
} #No action if j<i; elements already reordered
return
end
else if(i==j) #Conjugate only if j==i
y(i